/**
 * @param {number[][]} matrix
 * @param {number} target
 * @return {boolean}
 */
var findNumberIn2DArray = function(matrix, target) {
    if (matrix.length == 0 || matrix[0].length == 0) return false
    let x = 0;
    let y = matrix[0].length - 1;
    while (y>=0  &&  x <= matrix.length - 1) {
        if (matrix[x][y] == target) {
            return true
        }else if (matrix[x][y]> target){
            y--
        }else {
            x++
        }
    }
    return false
};
let target = 5
let matrix = [
    [1,4,7,11,15],
    [2,5,8,12,19],
    [3,6,9,16,22],
    [10,13,14,17,24],
    [18,21,23,26,30],
]
console.log(matrix.length)
console.log(findNumberIn2DArray(matrix,target))